home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / Documentation / Engineering Notes / Windows / Floating Windows
Encoding:
Text File  |  1996-04-26  |  3.5 KB  |  82 lines  |  [TEXT/ttxt]

  1. OpenDoc
  2. Development
  3. Framework
  4.                                                                                                                                                                                      
  5. Floating Windows
  6. ODF Release 1                                                                                                                                                             
  7.  
  8. Although the use-interface guidelines presented in the section "Palettes and Toolbars" on page 531 of the OpenDoc Programmer's Guide state that palettes should be hidden whenyour part becomes inactive it is also stated that when the active state switches between two identical part editors, then utility windows should remain steadily visible. On way to implement this behavior is to have utility windows shared among all instances of your part contained in a document.
  9.  
  10. ODF does that automatically for you. Only floating windows like palettes are shareable in this release but we will extend these capabilities to other utility windows like modeless dialogs in future releases.
  11.  
  12. This document describes in detail how to add a shared palette to your part. ODFDraw is currently the only ODF sample supporting palettes. 
  13.  
  14. • In your CMyPart class declare a fPalette, fPaletteFrame, and fPalettePresentation field
  15.  
  16. class CMyPart : public FW_CPart
  17. {
  18. public:
  19.     ......
  20.  
  21. private:
  22.     FW_CFloatingWindow*                 fPaletteWindow;
  23.     CMyPaletteFrame*                                fPaletteFrame;
  24.     CMyPatettePresentation* fPalettePresentation;
  25.     .....
  26. };
  27.  
  28. Don't forget to initialize these fields to NULL in the CMyPart constructor.
  29.  
  30. • Register a presentation for your palette frame like you do for any other frames.
  31.  
  32.     fPalettePresentation         = RegisterPresentation(ev, kPalettePresentation, FALSE);
  33.  
  34. • Create an instance of FW_CFloatingWindow in your override of FW_CPart::Intialize. This just creates and instance of FW_CFloatingWindow. The creation of the platform Window, ODWindow and ODFrame are delayed until the palette is shown. 
  35.  
  36.     fPaletteWindow = new FW_CFloatingWindow(ev, 
  37.                                                                                                                                                                     this,                                                                         // your Part instance
  38.                                                                                                                                                                     fPalettePresentation, 
  39.                                                                                                                                                                     FW_CString32(""),                         // no title
  40.                                                                                                                                                                     paletteSize, 
  41.                                                                                                                                                                     palettePosition,
  42.                                                                                                                                                                     TRUE);                                                                        // Close Box
  43.  
  44.  
  45. • In your override of CMyPart::NewFrame add the following code:
  46.  
  47. FW_CFrame* CMyPart::NewFrame(Environment* ev, 
  48.                                 ODFrame* odFrame, 
  49.                                 FW_CPresentation* presentation,
  50.                                 FW_Boolean fromStorage)
  51. {
  52.     if (presentation == fPalettePresentation)
  53.     {
  54.         if (fPaletteFrame)
  55.             return fPaletteFrame;
  56.         else
  57.             return (fPaletteFrame = FW_NEW(CPaletteFrame, (ev, odFrame, presentation, this)));
  58.     }
  59.     else .....
  60. }
  61.  
  62. • To display your palette just call:
  63.  
  64. fPaletteWindow->ShowHide(ev, TRUE);
  65.  
  66. The palette will be shown for all instances of your part contained in a document.
  67.  
  68. • In your overide of FW_CPart::ReleaseAll dispose the FW_CFloatingWindow by calling:
  69.  
  70. void CMyPart::ReleaseAll(Environment *ev)
  71. {
  72.     FW_CPart::ReleaseAll(ev);
  73.     
  74.     delete fPaletteWindow;
  75.     fPaletteWindow = NULL;
  76. }
  77.  
  78. This will delete your FW_CFloatingWindow instance and, if your part is the last one, ODF will also release the ODWindow and ODFrame associated with it.
  79.  
  80.  
  81. © 1993 - 1996 Apple Computer, Inc. All rights reserved.
  82. Apple, the Apple Logo, Macintosh, and OpenDoc are trademarks of Apple Computer, Inc., registered in the United States and other countries.